const mongoose = require('mongoose')
const generateRandom = require('../utils/dateFormat').generateRandom
const dateFormat = require('../utils/dateFormat').formatDate
const Schema = mongoose.Schema
mongoose.set('useFindAndModify', false)
// console.log('generateRandom', generateRandom())
const RepositoryInSchema = new Schema({
  ReInNum: {
    type: String,
    required: false,
    default: generateRandom()
  },
  inDate: {
    type: String,
    required: false,
    default: dateFormat(new Date(), true)
  },
  // 经办人
  principal: {
    type: String,
    required: true,
    minlength: 1,
    maxlength: 10
  },
  createdAt: {
    type: String,
    required: false,
    default: dateFormat(new Date(), true)
  },
  blood: {
    type: mongoose.Schema.Types.ObjectId,
    refs: 'Blood'
  },
  isDeleted: {
    type: Number,
    required: false,
    select: false,
    default: 0
  },
})

module.exports = RepositoryIn = mongoose.model('RepositoryIns', RepositoryInSchema)
